package es.kix2902.testing.android.testing;

import java.io.*;
import java.net.URL;
import android.util.Log;

public class HttpGet
{
	public static Double download(String dest)
	{
		String str;
		String ret = new String();
		StringBuffer buff = new StringBuffer();
		
		try 
		{
			URL url = new URL("http://www.webservicex.net:80/CurrencyConvertor.asmx/ConversionRate?FromCurrency=EUR&ToCurrency=" + dest);
			
			BufferedReader in = new BufferedReader(new InputStreamReader(url.openStream()));
			while ((str = in.readLine()) != null)
			{
				buff.append(str);
			}
			
			ret = buff.toString();
			
			ret = ret.substring(ret.indexOf(">", ret.indexOf(">")+1)+1, ret.indexOf("</"));
		} catch (Exception e) {
			Log.e("HttpRequest", e.toString());
		}
		
		return Double.parseDouble(ret);
	}
	
}
